/**
 * Copyright (c) 2018 软唐 All rights reserved.
 *
 * https://www.softtown.cn
 *
 * 版权所有，侵权必究！
 */

package com.softtown.modules.dapai.controller;

import com.github.pagehelper.PageInfo;
import com.softtown.common.utils.Result;
import com.softtown.modules.dapai.dto.CompServiceOrderAPPDTO;
import com.softtown.modules.dapai.dto.CompServiceOrderAddDTO;
import com.softtown.modules.dapai.dto.CompServiceOrderDTO;
import com.softtown.modules.dapai.service.CompServiceOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* @Author: Ding Ya Yong
* @Description: 维修服务单
* @date: 2022/1/2 20:47
* @Param:
* @return:
*/
@RestController
@RequestMapping("serviceOrder")
@Api(tags="维修服务单")
public class CompServiceOrderController {

    @Resource
    private CompServiceOrderService compServiceOrderService;

    @PostMapping("getServiceOrderPageList")
    @ApiOperation("获取维修服务单分页")
    public Result getServiceOrderPageList(@RequestBody CompServiceOrderDTO compServiceOrderDTO) {
        PageInfo<CompServiceOrderDTO> compServiceOrderDTOPageInfo = compServiceOrderService.getServiceOrderPageList(compServiceOrderDTO);
        return new Result<PageInfo<CompServiceOrderDTO>>().ok(compServiceOrderDTOPageInfo);
    }



    @PostMapping("getServiceOrderById")
    @ApiOperation("获取维修服务单详情")
    public Result<CompServiceOrderAddDTO> getServiceOrderById(@RequestBody CompServiceOrderDTO compServiceOrderDTO) {
        CompServiceOrderAddDTO compServiceOrderAddDTO = compServiceOrderService.getServiceOrderById(compServiceOrderDTO.getCompId(),compServiceOrderDTO.getId());
        return new Result<CompServiceOrderAddDTO>().ok(compServiceOrderAddDTO);
    }


    @PostMapping("getServiceOrderPageListAPP")
    @ApiOperation("获取维修服务单分页APP")
    public Result getServiceOrderPageListAPP(@RequestBody CompServiceOrderAPPDTO compServiceOrderAPPDTO) {
        PageInfo<CompServiceOrderAPPDTO> compServiceOrderAPPDTOPageInfo = compServiceOrderService.getServiceOrderPageListAPP(compServiceOrderAPPDTO);
        return new Result<PageInfo<CompServiceOrderAPPDTO>>().ok(compServiceOrderAPPDTOPageInfo);
    }



    @PostMapping("getServiceOrderByIdAPP")
    @ApiOperation("获取维修服务单详情APP")
    public Result<CompServiceOrderAPPDTO> getServiceOrderByIdAPP(@RequestBody CompServiceOrderAPPDTO compServiceOrderAPPDTO) {
        CompServiceOrderAPPDTO compServiceOrderAPPDTO1 = compServiceOrderService.getServiceOrderByIdAPP(compServiceOrderAPPDTO.getCompId(),compServiceOrderAPPDTO.getId());
        return new Result<CompServiceOrderAPPDTO>().ok(compServiceOrderAPPDTO1);
    }

    @PostMapping("submitServiceOrderAPP")
    @ApiOperation("提交维修服务单APP")
    public Result submitServiceOrderAPP(@RequestBody CompServiceOrderAPPDTO compServiceOrderAPPDTO) {
        Result result = new Result<>();
        compServiceOrderService.submitServiceOrderAPP(compServiceOrderAPPDTO);
        return result;
    }


    @PostMapping("addServiceOrder")
    @ApiOperation("添加维修服务单")
    public Result addServiceOrder(@RequestBody CompServiceOrderAddDTO CompServiceOrderAddDTO) {
        Result result = new Result<>();
        compServiceOrderService.addServiceOrder(CompServiceOrderAddDTO);
        return result;
    }

    @PostMapping("updateServiceOrder")
    @ApiOperation("修改维修服务单")
    public Result updateServiceOrder(@RequestBody CompServiceOrderAddDTO CompServiceOrderAddDTO) {
        Result result = new Result<>();
        compServiceOrderService.updateServiceOrder(CompServiceOrderAddDTO);
        return result;
    }

    @PostMapping("deleteServiceOrder")
    @ApiOperation("删除维修服务单")
    public Result deleteServiceOrder(@RequestBody CompServiceOrderDTO compServiceOrderDTO) {
        Result result = new Result<>();
        compServiceOrderService.deleteServiceOrder(compServiceOrderDTO);
        return result;
    }

}
